/**
 * <pre>
 * @(#)Amplitude.java 1.00 2009-11-12
 * 
 * Copyright (c) 1998, 2009 Regular Individual. All rights reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *    http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * Contributor(s):
 *     Haixu Huang
 * </pre>
 **/
package cn.sh.huang.chart.ext.enumtype;

/**
 * <pre>
 * Amplitude ...
 * 
 * @version 1.0
 * </pre>
 */
public class Amplitude extends Enum
{
    private final double base, ratio;

    private Amplitude(String name, double ratio)
    {
        super(name);
        this.base = (1 - ratio) / 2;
        this.ratio = ratio;
    }

    public Integer getAmplitude(Double nomalized, int max)
    {
        return (nomalized == null) ? null : new Integer((int) Math
            .round((nomalized.doubleValue() * ratio + base) * max));
    }

    public static final Amplitude FULL = new Amplitude("100%", .8333), ALMOST = new Amplitude("75%", .6667),
            HALF = new Amplitude("50%", .5), THIN = new Amplitude("25%", .3333);

}
